<!DOCTYPE html>
<html>
    
    <head lang="en">
        <meta charset="UTF-8">
        <title>注册</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="format-detection" content="telephone=no">
        <meta name="renderer" content="webkit">
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" href="/static/myhome/AmazeUI-2.4.2/assets/css/amazeui.min.css" />
        <link href="/static/myhome/css/dlstyle.css" rel="stylesheet" type="text/css">
        <script src="/static/myhome/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
        <script src="/static/myhome/AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
    </head>
    
    <body>
        <div class="login-boxtitle">
            <a href="home/demo.html">
                <img alt="" src="/static/myhome/images/logobig.png" /></a>
        </div>
        <div class="res-banner">
            <div class="res-main">
                <div class="login-banner-bg">
                    <span></span>
                    <img src="/static/myhome/images/big.jpg" /></div>
                <div class="login-box">
                    <div class="am-tabs" id="doc-my-tabs">
                        <ul class="am-tabs-nav am-nav am-nav-tabs am-nav-justify">
                            <li class="am-active"><a href="">手机号注册</a></li>
                        </ul>
                        <div class="am-tabs-bd">
                            <div class="am-tab-panel am-active">
                                <form method="post">
                                    {% csrf_token %}
                                    <div class="user-phone">
                                        <label for="phone">
                                            <i class="am-icon-mobile-phone am-icon-md"></i>
                                        </label>
                                        <input type="tel" name="phone" id="phone" placeholder="请输入手机号"></div><div class="verification">
                                        <label for="code">
                                            <i class="am-icon-code-fork"></i>
                                        </label>
                                        <input type="tel" name="code" id="code" style="width: 55%;"  placeholder="请输入验证码">
                                        <button type="button" class="btn" id="sendMobileCode">获取短信验证码</button>
                                    </div>
                                    <div class="user-pass">
                                        <label for="passwordRepeat">
                                            <i class="am-icon-user"></i>
                                        </label>
                                        <input type="text" name="username" id="passwordRepeat" placeholder="请设置用户名"></div>
                                    <div class="user-pass">
                                        <label for="password">
                                            <i class="am-icon-lock"></i>
                                        </label>
                                        <input type="password" name="password" id="password" placeholder="设置密码"></div>
                                <div class="am-cf">
                                    <input type="submit" name="" value="注册" class="am-btn am-btn-primary am-btn-sm am-fl"></div>
                                <hr>
                                </div>
                                </form>
                            <script>
                                var tel = false;
                                var phone = null;
                                // 定义发送手机验证码的函数
                                $('#sendMobileCode').click(function(){
                                    // 手机号正确,则发送验证码,不正确,则提醒
                                    if(!tel){
                                        alert('手机号不正确')
                                        return;
                                    }
                                    // 发送ajax请求.给手机号发送验证码
                                    $.get('{% url 'myhome_sendmsg' %}',{'phone':phone},function(data){
                                        console.log(data)
                                    },'json')

                                    // 定时器,倒计时
                                    var num = 60
                                    var i = setInterval(function(){
                                        num -- 
                                        if(num <=0){
                                            $('#sendMobileCode').text('获取短信验证码').prop("disabled",false);
                                            clearIntervals(i)
                                        }else{
                                            $('#sendMobileCode').text('提交成功('+num+'秒)').prop("disabled",true);
                                        }
                                    },1000)

                                })
                                // 给手机号绑定丧失焦点事件
                                $('#phone').blur(function(){
                                    // 获取输入的手机号,验证是否正确,验证是否存在
                                    phone = $(this).val()
                                    var reg = /^1[3|4|5|7|8|9][0-9]{9}$/
                                    if(!reg.test(phone)){
                                        // 手机号不正确
                                        alert('手机号的格式有误！')
                                        tel = false
                                        return; 
                                    }
                                    //发送ajax验证手机号是否存在
                                    $.get('{% url 'myhome_checkPhone' %}',{'phone':phone},function(data){
                                        if(data.error){
                                            // 不能使用,已经注册
                                            alert('该手机号已被注册！')
                                            tel = false
                                        }else{
                                            tel = true
                                        }
                                    },'json')
                                })
                            </script>
                        </div>
                    </div>
                </div>
            </div>
            <div class="footer ">
                <div class="footer-hd ">
                    <p>
                        <a href="# ">恒望科技</a>
                        <b>|</b>
                        <a href="# ">商城首页</a>
                        <b>|</b>
                        <a href="# ">支付宝</a>
                        <b>|</b>
                        <a href="# ">物流</a></p>
                </div>
                <div class="footer-bd ">
                    <p>
                        <a href="# ">关于恒望</a>
                        <a href="# ">合作伙伴</a>
                        <a href="# ">联系我们</a>
                        <a href="# ">网站地图</a>
                        <em>© 2015-2025 Hengwang.com 版权所有</em></p>
                </div>
            </div>
    </body>
</html>